<extend name="Layout/ins_popup" />
<block name="content">
	<style>
		.progress {
			position: relative;
			background-color: #e2e2e2;
			border-radius: 2px;
			box-sizing: border-box;
			display: block;
			height: 20px;
			line-height: 18.5714px;
			margin-bottom: 0px;
			margin-top: 0px;
			overflow-x: hidden;
			overflow-y: hidden;
			text-align: center;
			border: 0px solid #ccc;
		}
		.progress .label {
			position: absolute;
			width: 100%;
			line-height: 20px;
			background-color: transparent;
		}
		.progress-bar {
			position: absolute;
			background-color: #2794EB;
			box-shadow: none;
			box-sizing: border-box;
			color: rgb(255, 255, 255);
			display: block;
			font-size: 12px;
			height: 20px;
			line-height: 20px;
			list-style-image: none;
			list-style-position: outside;
			list-style-type: none;
			margin-bottom: 0px;
			text-align: center;
			transition-delay: 0s;
			transition-duration: 0.6s;
			transition-property: width;
			transition-timing-function: ease;
		}
	</style>
	<div class="popup-frame">
		<input type="hidden" name="val" id="val">
		<input type="hidden" name="name" id="name">
		<div class="popup-header ">
			<div class="pull-left">
				<h1>同步到微信</h1>
			</div>
			<div class="pull-right">
				<a id='close' class="btn btn-cancel">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<div class="progress progress-mini text-center">
						<div class="progress-bar" id="data_1"></div>
						<div class="label">
							<span id="data_2"></span>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			var counter = 0;
			var interval = setInterval(function() {
				var d = new Date();
				var vars = 'rand=' + d.getTime();
				send_ajax("{:U('sync_to_wechat')}", vars, function(ret) {
					$("#data_1").css('width', ret.percentage + '%');
					$("#data_2").text(ret.percentage + '%');
					if (ret.status == 3) {
						clearInterval(interval);
					}
				});
			}, 2000);

			//关闭iframe
			$('#close').click(function() {
				parent.layer.close(index);
			});

		});
	</script>
</block>